package com.ft.oa.domain.dto;

import com.ft.oa.enums.ResultCode;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Accessors(chain = true)
public class ApiResult {
    private Integer code;

    private String msg;

    private Object data;

    public static ApiResult simpleSuccess(){

        return ApiResult.builder().code(200).msg("成功").build();
    }

    public static ApiResult successWithData(Object data){

        return ApiResult.builder().code(200).msg("成功").data(data).build();
    }

    public static ApiResult fail(){
        return ApiResult.builder().code(ResultCode.SERVICE_ERR.getCode()).msg(ResultCode.SERVICE_ERR.getMsg()).build();
    }
}

